﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Management;
using System.Text;
using System.Net;
using System.Runtime.InteropServices;
namespace stock.test
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        [DllImport("Iphlpapi.dll")]
        private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);
        [DllImport("Ws2_32.dll")]
        private static extern Int32 inet_addr(string ip);

        private void Page_Load(object sender, System.EventArgs e)
        {
            Response.Write(Request.ServerVariables["SERVER_NAME"].ToLower() + "<br/>");
            Response.Write(Request.ServerVariables["Http_Host"].ToLower() + "<br/>");
            Response.Write(Request.Path + "<br/>");
            Response.Write(Page.Request.UserHostName);
            foreach (string key in Request.ServerVariables)
            {
                Response.Write(key + "：" + Request.ServerVariables[key] + "<br/>");
            }
        }
        private string GetClientIP()
        {
            string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (null == result || result == String.Empty)
            {
                result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            }
            if (null == result || result == String.Empty)
            {
                result = HttpContext.Current.Request.UserHostAddress;
            }
            return result;
        }
    }
}